package jianzhiOffer;

public class MaxWordLength {
    public int maxProduct(String[] words) {
        int n = words.length;
        int[] arr = new int[n];
        int index = 0;
        for(String str : words) {
            int t = 0;
            for(int i = 0; i < str.length(); i++) {
                int u = str.charAt(i) - 'a';
                t |= (1 << u);
            }
            arr[index++] = t;
        }
        int maxLength = 0;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < i; j++) {
                if((arr[i] & arr[j]) == 0) maxLength = Math.max(maxLength,words[i].length() * words[j].length());
            }
        }
        return maxLength;
    }
}
